# !/usr/bin/env bash
echo "打包开始"
rm -f -r dist
npm run build
echo "打包完成"
echo "压缩开始"
cd ./dist
zip -r dist.zip .
echo "压缩完成"
cd ..
curl -L -H "Content-Type:application/json" -X POST -d '{"username":"xxxxx","password":"xxxxxxx"}' -b cookie -c cookie http://xxx.xxxxxxxxx.com:xxxxxx/xxxx/xxxxx/xxxxx/login > resultInfo.json
echo "登录结果：" 
cat ./resultInfo.json | awk -F '[:,}"]' '{for(i=1;i<=NF;i++){if($i == "result") print$(i+2)}}'
distFile="./dist/dist.zip"
curl -b cookie -F "file=@${distFile}" http://xxx.xxxxxxxxx.com:xxxxxx/xx/xxxxx/xxxxx?xxxxxxx=/test > resultInfo.json
echo "部署结果：" 
cat ./resultInfo.json | awk -F '[:,}"]' '{for(i=1;i<=NF;i++){if($i == "result") print$(i+2)}}'
rm  ./cookie
rm  ./resultInfo.json
exec /bin/bash
